package com.aurora.app.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.aurora.base.entity.BaseEntity;


@Entity
@Table(name="tb_thing_story")
public class ThingStory extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	private User user;
	
	private String title;
	
	//图片
	private List<ThingStoryImage> images;// 图片内容
	
	private String content;
	
	private Integer zan = 0;
	
	private Integer state;
	
	private Integer view = 0;

	//专题
	private StoryTopic storyTopic; 

	@ManyToOne(cascade = {CascadeType.REFRESH}, optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "f_user_id")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name="f_title")
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}


	@Column(name="f_content")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name="f_zan")
	public Integer getZan() {
		return zan;
	}

	public void setZan(Integer zan) {
		this.zan = zan;
	}

	@Column(name="State")
	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}
	@Column(name="view")
	public Integer getView() {
		return view;
	}

	public void setView(Integer view) {
		this.view = view;
	}
	
	@OneToMany(fetch = FetchType.EAGER, mappedBy = "thingStory", cascade = {CascadeType.ALL})
	@OrderBy("createTime desc")
	public List<ThingStoryImage> getImages() {
		return images;
	}

	public void setImages(List<ThingStoryImage> images) {
		this.images = images;
	}

	@ManyToOne(cascade = {CascadeType.REFRESH}, optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "f_topic_id")
	public StoryTopic getStoryTopic() {
		return storyTopic;
	}

	public void setStoryTopic(StoryTopic storyTopic) {
		this.storyTopic = storyTopic;
	}
	
}
